package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressBookMapper {
    /**
     * 新增一个地址
     * @param addressBook
     */
    void insert(AddressBook addressBook);

    /**
     * 查询所有的地址
     */
    @Select("SELECT * from address_book")
    List<AddressBook> selectAll();

    /**
     * 查询默认地址
     * @return
     */
    @Select("select * from address_book where is_default=#{0}")
    AddressBook selectDef();

    /**
     * 查询当前制定id的信息
     * @param id
     * @return
     */
    @Select("select * from address_book where user_id=#{id}")
    AddressBook selectById(Long id);

    /**
     * 查询当前制定id的信息
     * @param id
     * @return
     */
    @Select("select * from address_book where id=#{id}")
    AddressBook selectByAdminId(Long id);


    /**
     * 设置默认的地址
     * @param
     */
    void update(AddressBook addressBook);

    /**
     * 根据id删除
     * @param id
     */
    @Delete("delete from address_book where id=#{id}")
    void delete(Long id);
}
